package com.itheima.socketWoek02;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class ServerDemo01 {
    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(10088);
        System.out.println("等待中:");
        Socket socket = serverSocket.accept();

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                socket.getInputStream()
        ));

        PrintWriter writer = new PrintWriter(socket.getOutputStream(), true);

        String line;
        while ((line = reader.readLine()) != null) {
            //writer.write(line);
            String revLine = new StringBuilder(line).reverse().toString();
            writer.println(revLine);
        }
        serverSocket.close();


    }
}
